package com.legal.controller.voice_recognition;


import com.legal.domain.result.Result;
import com.legal.service.speech_recognition.VoiceRecognition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 语音识别控制器
 *
 * @author xiaopeng
 * @version 1.0
 */
@RequestMapping("/ai/voice")
@RestController
@RequiredArgsConstructor
@Slf4j
@Tag(name = "语音识别")  // OpenAPI 3.0 注解
public class VoiceRecognitionController {

    private final VoiceRecognition voiceRecognition;


    /**
     * 语音识别接口
     *
     * @param audioFile 上传的音频文件
     * @param language  语言选项(可选)
     * @return 识别结果
     */
    @PostMapping("/recognize")
    @Operation(summary = "语音识别")
    public Result<String> recognize(
            @RequestParam("audio") MultipartFile audioFile,
            @RequestParam(value = "language", required = false, defaultValue = "chinese") String language) {
        return voiceRecognition.voiceRecognize(audioFile, language);
    }
}
